using System.Collections.Generic;
using System.Runtime.Serialization;

namespace IppServer.Host.Configuration
{
    /// <summary>
    /// IP/MAC地址限制配置
    /// </summary>
    [DataContract]
    internal sealed class IpMacRestriction
    {
        /// <summary>
        /// 是否启用IP/MAC限制
        /// </summary>
        [DataMember(Order = 0)]
        public bool Enabled { get; set; }

        /// <summary>
        /// 限制模式：true=白名单模式（仅允许列表中的地址），false=黑名单模式（禁止列表中的地址）
        /// </summary>
        [DataMember(Order = 1)]
        public bool WhitelistMode { get; set; } = false;

        /// <summary>
        /// IP地址规则列表（单个IP、IP范围、CIDR网段）
        /// 例如：["192.168.1.100", "192.168.1.0/24", "10.0.0.1-10.0.0.50"]
        /// </summary>
        [DataMember(Order = 2, EmitDefaultValue = true)]
        public List<string> IpRules { get; set; } = new List<string>();

        /// <summary>
        /// MAC地址规则列表（支持通配符，如 "00:11:22:*:*:*"）
        /// </summary>
        [DataMember(Order = 3, EmitDefaultValue = true)]
        public List<string> MacRules { get; set; } = new List<string>();

        public static IpMacRestriction CreateDefault()
        {
            return new IpMacRestriction
            {
                Enabled = false,
                WhitelistMode = false,
                IpRules = new List<string>(),
                MacRules = new List<string>()
            };
        }
    }
}

